#!/bin/sh

for filename in *.zip
do
	7z x "${filename}" -pinfected
done
for filename in *.elf
do
	if [ -n "$(file "${filename}" | grep ARM)" ]
	then
		mv "${filename}" "${filename}.arm"
	fi
	if [ -n "$(file "${filename}" | grep MIPS)" ]
	then
		mv "${filename}" "${filename}.mips"
	fi
	if [ -n "$(file "${filename}" | grep 0386)" ]
	then
		mv "${filename}" "${filename}.x86"
	fi
	if [ -n "$(file "${filename}" | grep x86-64)" ]
	then
		mv "${filename}" "${filename}.x86_64"
	fi
	if [ -n "$(file "${filename}" | grep Power)" ]
	then
		mv "${filename}" "${filename}.ppc"
	fi
	if [ -n "$(file "${filename}" | grep SPARC)" ]
	then
		mv "${filename}" "${filename}.sparc"
	fi
	if [ -n "$(file "${filename}" | grep SH)" ]
	then
		mv "${filename}" "${filename}.sh"
	fi
	if [ -n "$(file "${filename}" | grep m68k)" ]
	then
		mv "${filename}" "${filename}.m68k"
	fi
done
for filename in *.elf*
do
	/usr/local/src/upx-trunk/src/upx.out -d -o "${filename}.unpacked" "${filename}"
done
clamscan *.elf*
